import lejos.nxt.*;

public class DistanceSensor extends Thread {
	private DistanceMonitor monitor;
	private UltrasonicSensor sensor;

	public DistanceSensor(DistanceMonitor monitor, UltrasonicSensor sensor) {
		this.monitor = monitor;
		this.sensor = sensor;
	}

	public void run() {
		while (true) {
			try {
				Thread.sleep(100);
			} catch (InterruptedException e) {
				e.printStackTrace();
			}
			monitor.setDistance(sensor.getDistance());
		}
	}
}
